package reivew;

/**
 * @author oldliu
 * @since 1.0
 */
public class GetPosition {

    public static void main(String[] args) {
        int arr[] = {111, 100,93,75,66,128}, i,j, k;
        for ( i = 0; i < arr.length; i++) {
            boolean left=true;//假定都满足
            boolean right=true;
            //循环的时候，找到一个不满足的就可以了
            //判断左边
            for (j = 0; j<=i-1; j++) {
                if (arr[i] < arr[j]){
                    left=false;
                    break;
                }
            }
            if(!left)
                continue;
            //判断右边
            for (k = i + 1; k < arr.length; k++) {
                if (arr[i] > arr[k]) {
                    right=false;
                    break;
                }
            }
            if(left&&right){
                System.out.println("数字：" + arr[i] + "位置" + i);
                return;
            }
        }
        System.out.println("没有符合条件的数！");

    }
}
